﻿//*** Guidance generated code ***//
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;

using ProjectBase.Core;

namespace $safeprojectname$
{
    /// <summary>
    ///     Project main root of Persistent objects.
    ///     Can be extended this object with some sommon/shared properties
    ///     e.g. IsVisible, EditedBy ....
    /// </summary>
    [Serializable]
    public abstract class Persistent<TID> : PersistentObjectWithTypedId<TID>, ISetID<TID>
    {
        #region String representation
        /// <summary>
        ///     ToString is not used for Catharsis purposes.
        ///     For debug it is usefull to quickly see the real instance of the object
        ///     (instaed of the Type name).
        ///     If ToString() is needed another way - override it
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return "ID: " + ID + " - " + ToDisplay();
        }
        #endregion String representation

        #region ISetID<TID> Members
        /// <summary>
        ///     allows to set ID on DAO
        /// </summary>
        /// <param name = "id"></param>
        void ISetID<TID>.SetID(TID id)
        {
            SetID(id);
        }
        protected void SetID(TID id)
        {
            ID = id;
        }
        #endregion
    }
}